<?php

namespace App\Models;

class Authitem extends Base
{
    public function getAuthitem($clubId = 0)
    {
        $sql = "select * from tb_auth_item where club_id in (0, ?) and deleted = 0 order by id asc";
        $results = $this->fetchAll($sql, [$clubId]);
        $baseAuthItem = array_map(function(&$item){
            if (!$item['club_id']) {
                return $item;
            }
        }, $results);
        $clubAuthItem = array_map(function(&$item){
            if ($item['club_id']) {
                return $item;
            }
        }, $results);
        return ['base' => array_filter($baseAuthItem), 'club' => array_filter($clubAuthItem)];
    }
}
